<?php

namespace app\admin\controller;

use app\BaseController;
use app\lib\upload\Qiniu;

class Index extends BaseController
{
    public function uploadImage()
    {
        $filePath = request()->file('file');
        $result = Qiniu::upload($filePath);
        if ($result) {
            return show(200, '图片上传成功', $result);
        } else {
            return show(config('status.upload_error'), '图片上传失败');
        }
    }

    public function uploadVoice()
    {
        $filePath = request()->file('file');
        $result = Qiniu::upload($filePath);
        if ($result) {
            return show(200, '音频上传成功', $result);
        } else {
            return show(config('status.upload_error'), '音频上传失败');
        }
    }

    public function uploadVideo()
    {
        $filePath = request()->file('file');
        $result = Qiniu::upload($filePath);
        if ($result) {
            return show(200, '视频上传成功', $result);
        } else {
            return show(config('status.upload_error'), '视频上传失败');
        }
    }
}
